package com.zkq.basic_dl;

import com.zkq.oftype.OfType;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Map;

public class QuickstartByNameApplication {

    public static void main(String[] args) {

//        IOC依赖注入的byName方式
        BeanFactory beanFactory=new ClassPathXmlApplicationContext("basic_dl/quickstart-bytype.xml");
        Person person = (Person)beanFactory.getBean("person");
        System.out.println(person);


//        IOC依赖注入的byType方式
        Person bean = beanFactory.getBean(Person.class);
        System.out.println(bean);


        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("basic_dl/of_type.xml");
        Map<String, OfType> beansOfType = applicationContext.getBeansOfType(OfType.class);
        beansOfType.forEach((name,impl)->{
            System.out.println(name+">>>>"+impl.toString());
        });

        //

    }
}
